package cn.tude;

import java.io.File;
import java.util.Scanner;

public class Test_digui {
    public static void main(String[] args) {
        System.out.println("请输入文件夹");
        String path = new Scanner(System.in).nextLine();
        File aa = new File(path);
       long sum=sizeof(aa);
        System.out.println("文件夹是"+aa+",总大小是"+sum);

    }
        public static long sizeof(File aa){
            File[] ss = aa.listFiles();
            long size = 0;
            for (int i = 0; i < ss[i].length(); i++) {
                if (ss[i].isFile()) {
                    size = size + ss[i].length();
                } else if (ss[i].isDirectory()) {

                    size = size + sizeof(ss[i]);


                }

            }
            return size;
        }
    }

